package com.cskaoyan.controller.system;

import com.cskaoyan.bean.MallLog;
import com.cskaoyan.model.bo.PageBo;
import com.cskaoyan.model.vo.BaseRespVo;
import com.cskaoyan.model.vo.PageListVo;
import com.cskaoyan.service.system.LogService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: project-market
 * @description: 日志管理
 * @author: Weiwei Liu
 * @create: 2021-11-30 17:14
 **/
@RestController
@RequestMapping("admin/log")
public class LogController {

    @Autowired
    LogService logService;


    @RequiresPermissions("admin:log:list")
    @RequestMapping("list")
    public BaseRespVo list(PageBo pageBo, String name) {

        PageListVo vo = logService.list(pageBo, name);

        return BaseRespVo.ok(vo);
    }


    @RequiresPermissions("admin:log:create")
    @PostMapping("create")
    public BaseRespVo create(MallLog mallLog) {

        boolean status = logService.create(mallLog);

        if(status) return BaseRespVo.ok();

        return BaseRespVo.fail("存储log失败");
    }
}
